package com.tonicgb.shared.common.response;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author zhaiyujin
 * @date 2021-09-01 16:52:14
 * @说明 统一返回结果
 */
@Data
@ApiModel("Result")
public class Result {

    public static final int OK = 0;
    public static final int ERROR = 1;
    public static final String DEFAULT_MESSAGE="系统异常";
    public static final String SYSTEM_BUSSY="系统繁忙";
    public static final int VALIDATE_ERROR = 40000;

    @ApiModelProperty("数据")
    private Object data;

    @ApiModelProperty("描述")
    private String message;
    @ApiModelProperty("状态码")
    private int code;

    public Result() {
    }


    public Result(Object data, String message, int code) {
        this.data = data;
        this.message = message;
        this.code = code;
    }

    public static Result success(Object data) {
        return new Result(data, "OK", OK);
    }
    public static Result success() {
        return new Result(null, "OK", OK);
    }
    public static Result error(int code, String message) {
        return new Result(null, message, code);
    }

    public static Result error( String message) {
        return new Result(null, message, 400);
    }


}
